package mspbots.data.sync.logs.controller;


import lombok.RequiredArgsConstructor;
import mspbots.data.sync.logs.entity.ExceptionLogs;
import mspbots.data.sync.logs.service.ExceptionLogsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/logs")
@RequiredArgsConstructor
public class SyncDataLogController {

    private final ExceptionLogsService exceptionLogsService;

    /**
     * {
     * "startTime": "2020-05-26T00:00:00Z",
     * "endTime": "2020-05-26T23:59:59Z",
     * "tenantId": 1001,
     * "interfaceName": "/api/1.0/folders",
     * "status": 500
     * }
     */
    @PostMapping("/selectGrabLog")
    public Flux<ExceptionLogs> selectGrabLog(@RequestBody ExceptionLogs entity) {
        return exceptionLogsService.selectGrabLog(entity);
    }


    /**
     * {
     * "startTime": "2020-05-26T00:00:00Z",
     * "endTime": "2020-05-26T23:59:59Z",
     * "tenantId": 1001,
     * "interfaceName": "/api/1.0/folders",
     * "status": 500
     * }
     */
    @PostMapping("/selectGrabLogDetail")
    public Flux<ExceptionLogs> selectGrabLogDetail(@RequestBody ExceptionLogs entity) {
        return exceptionLogsService.selectGrabLogDetail(entity);
    }

    /**
     * {
     * "startTime": "2020-05-26T00:00:00Z",
     * "endTime": "2020-05-26T23:59:59Z",
     * "tenantId": 1001,
     * "serviceName":  "time-doctor"
     * }
     */
    @PostMapping("/countGrabLogStatus")
    public Flux<ExceptionLogs> countGrabLogStatus(@RequestBody ExceptionLogs entity) {
        return exceptionLogsService.countGrabLogStatus(entity);
    }
}
